26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
50 #pragma package(smart_init)
63 Graphics::TBitmap* SmallGraphicPtrVal): SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
65 for(
int x = 0; x < 4; x++)
74 else if(SpeedTagVal == 77)
76 else if(SpeedTagVal == 78)
78 else if(SpeedTagVal == 79)
80 else if(SpeedTagVal == 96)
82 else if(SpeedTagVal == 129)
84 else if(SpeedTagVal == 130)
86 else if(SpeedTagVal == 131)
88 else if(SpeedTagVal == 145)
90 else if(SpeedTagVal == 146)
97 FixedNamedLocationElement(false)
99 for(
int x = 0; x < 4; x++)
110 AnsiString(VLocInput));
123 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
133 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
145 Graphics::TBitmap *GraphicOutput = GraphicPtr;
147 if(LocationName ==
"")
192 GraphicOutput = GraphicPtr;
196 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
205 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
206 AnsiString(TrainIDOnBridgeTrackPos01) +
"," + AnsiString(TrainIDOnBridgeTrackPos23) +
",EndTrkEl,";
215 if(lower.second < higher.second)
219 else if(lower.second > higher.second)
223 else if(lower.second == higher.second)
225 if(lower.first < higher.first)
238 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
239 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
243 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
254 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
282 {2, 4}, {6, 2}, {8, 6}, {4, 8},
283 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
291 else if(
Link[2] == -1)
300 else if(
Link[2] == -1)
308 for(
int x = 0; x < 16; x++)
310 if((Entry == EXArray[x][0]) && (Exit == EXArray[x][1]) || (Entry == EXArray[x][1]) && (Exit == EXArray[x][0]))
440 throw Exception(
"Error in EntryExitNumber 4");
516 throw Exception(
"Error in EntryExitNumber 5");
590 throw Exception(
"Error in EntryExitNumber 6");
657 throw Exception(
"Error in EntryExitNumber 10");
724 throw Exception(
"Error in EntryExitNumber 11");
797 throw Exception(
"Error in EntryExitNumber 7");
822 throw Exception(
"Error in EntryExitNumber 8");
833 if((ELink > 0) && (ELink < 10) && (ELink != 5))
835 if(!AutoSigsFlag && !PrefDirRoute)
837 else if(!AutoSigsFlag && PrefDirRoute)
844 throw Exception(
"Error in EntryExitNumber 9");
880 TTrack::TActiveLevelCrossing::TActiveLevelCrossing()
905 AnsiString NL =
'\n';
907 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable; " + NL + NL +
908 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
909 "blocked by a train, another route or a changing level crossing; " + NL + NL +
910 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
917 int InternalLinkCheckArray[9][2] =
918 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
923 for(
int x = 0; x < 9; x++)
924 for(
int y = 0; y < 2; y++)
928 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
930 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
931 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
932 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
933 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
934 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
941 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
943 for(
int x = 0; x < 10; x++)
944 for(
int y = 0; y < 2; y++)
950 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
953 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
954 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
956 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
957 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
959 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
960 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
963 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
966 for(
int x = 0; x < 40; x++)
972 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
975 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
976 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
978 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
979 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
981 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
982 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
985 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
988 for(
int x = 0; x < 40; x++)
994 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
997 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
998 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1000 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1001 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1003 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1004 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1007 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1010 for(
int x = 0; x < 40; x++)
1036 for(
int x = 0; x < 40; x++)
1063 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1064 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1065 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1066 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1067 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1068 {0, 0, 129}, {0, -1, 145},
1071 for(
int x = 0; x < 25; x++)
1072 for(
int y = 0; y < 3; y++)
1077 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1078 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1079 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1080 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1081 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1082 {0, 0, 129}, {0, 1, 145},
1085 for(
int x = 0; x < 25; x++)
1086 for(
int y = 0; y < 3; y++)
1091 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1092 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1093 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1094 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1095 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1096 {0, 0, 130}, {-1, 0, 146},
1099 for(
int x = 0; x < 25; x++)
1100 for(
int y = 0; y < 3; y++)
1105 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1106 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1107 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1108 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1109 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1110 {0, 0, 130}, {1, 0, 146},
1113 for(
int x = 0; x < 25; x++)
1114 for(
int y = 0; y < 3; y++)
1119 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1120 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1121 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1122 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1123 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1124 {0, -1, 129}, {1, 0, 130},
1125 {-1, 0, 130}, {0, 1, 145},
1126 {0, -1, 145}, {1, 0, 146},
1129 for(
int x = 0; x < 28; x++)
1130 for(
int y = 0; y < 3; y++)
1145 for(
int x = 0; x < 8; x++)
1146 for(
int y = 0; y < 3; y++)
1161 for(
int x = 0; x < 8; x++)
1162 for(
int y = 0; y < 3; y++)
1177 for(
int x = 0; x < 8; x++)
1178 for(
int y = 0; y < 3; y++)
1193 for(
int x = 0; x < 8; x++)
1194 for(
int y = 0; y < 3; y++)
1199 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1201 for(
int x = 0; x < 4; x++)
1202 for(
int y = 0; y < 3; y++)
1206 {0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1207 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1208 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1209 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1210 140, 144, 145, 146};
1213 {0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1214 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1215 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1216 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1217 141, 144, 145, 146};
1220 {0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1221 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1222 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1223 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1224 141, 144, 146, 145};
1227 {0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1228 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1229 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1230 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1231 140, 144, 146, 145};
1251 delete UGMIt->second;
1325 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1326 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1328 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1335 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1336 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1349 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1350 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1352 {4, 6, 2, 8}, {1, 9, 3, 7},
1354 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1356 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8
1357 }, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1360 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1361 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6
1363 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1365 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1
1367 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1368 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1370 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1373 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1374 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1375 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1376 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1377 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1378 {4, 6, -1, -1}, {2, 8, -1, -1},
1380 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1382 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1384 {4, 6, -1, -1}, {2, 8, -1, -1},
1389 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1390 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1391 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1392 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1395 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1396 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1397 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1399 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1400 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1401 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1403 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1405 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1406 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1407 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1408 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1409 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1410 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1411 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1412 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet
1414 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1415 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1416 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet
1418 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1419 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1421 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1422 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1423 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1424 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1425 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1426 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1427 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1428 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1432 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1433 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1434 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1440 for(
int x = 0; x < 17; x++)
1442 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1444 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1448 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1454 ExistingGraphicLoaded(false), Width(16), Height(16)
1466 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1504 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1508 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1512 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1516 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1539 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1542 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1546 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1550 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1584 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1605 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1619 bool TrackPresent =
false;
1633 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1636 TrackPresent =
true;
1640 return !TrackPresent;
1648 bool TrackPresent =
false;
1657 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1660 TrackPresent =
true;
1665 return !TrackPresent;
1670 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
1673 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1674 TrackEraseSuccessfulFlag =
false;
1679 ErasedTrackVectorPosition = -1;
1680 AnsiString SName =
"", ErrorString;
1682 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
1688 TrackMapKeyPair.first = HLocInput;
1689 TrackMapKeyPair.second = VLocInput;
1690 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
1701 if(ErrorString !=
"")
1703 throw Exception(ErrorString +
" for EraseTrackElement 1");
1726 ErasedTrackVectorPosition = VecPos;
1727 TrackEraseSuccessfulFlag =
true;
1734 unsigned int VecPos;
1735 InactiveTrackMapKeyPair.first = HLocInput;
1736 InactiveTrackMapKeyPair.second = VLocInput;
1741 VecPos = InactiveTrack2MultiMapIterator->second;
1746 if(ErrorString !=
"")
1748 throw Exception(ErrorString +
" for EraseTrackElement 2A");
1758 TrackEraseSuccessfulFlag =
true;
1778 VecPos = InactiveTrack2MultiMapIterator->second;
1783 if(ErrorString !=
"")
1785 throw Exception(ErrorString +
" for EraseTrackElement 2B");
1807 if(TrackEraseSuccessfulFlag)
1829 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1830 bool PlatAllowedFlag =
false;
1832 TrackLinkingRequiredFlag =
false;
1844 LocationNameEntry.first =
"";
1853 TempTrackElement.
HLoc = HLocInput;
1854 TempTrackElement.
VLoc = VLocInput;
1880 else if(Aspect == 1)
1882 else if(Aspect == 2)
1884 else if(Aspect == 3)
1890 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
1893 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
1895 if(InactiveFoundFlag)
1898 NonStationOrLevelCrossingPresent =
true;
1900 NonStationOrLevelCrossingPresent =
true;
1902 PlatformPresent =
true;
1913 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
1920 PlatAllowedFlag =
true;
1924 PlatAllowedFlag =
true;
1928 PlatAllowedFlag =
true;
1932 PlatAllowedFlag =
true;
1936 TrackLinkingRequiredFlag =
true;
1963 if((FoundFlag && (
NameAllowed.Contains(
TrackVector.at(VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
1964 (!FoundFlag && !InactiveFoundFlag))
1967 TrackLinkingRequiredFlag =
true;
2000 TrackLinkingRequiredFlag =
true;
2012 else if(FoundFlag || InactiveFoundFlag)
2032 bool BothPointFillets =
true;
2046 TrackLinkingRequiredFlag =
true;
2059 bool InternalChecks)
2063 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2064 bool PlatAllowedFlag =
false;
2066 TrackLinkingRequiredFlag =
false;
2069 LocationNameEntry.first =
"";
2076 TempTrackElement.
HLoc = HLocInput;
2077 TempTrackElement.
VLoc = VLocInput;
2078 for(
int x = 0; x < 4; x++)
2082 TempTrackElement.
Conn[x] = -1;
2086 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2097 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2099 if(InactiveFoundFlag)
2102 NonStationOrLevelCrossingPresent =
true;
2104 NonStationOrLevelCrossingPresent =
true;
2106 PlatformPresent =
true;
2117 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2124 PlatAllowedFlag =
true;
2128 PlatAllowedFlag =
true;
2132 PlatAllowedFlag =
true;
2136 PlatAllowedFlag =
true;
2140 TrackLinkingRequiredFlag =
true;
2170 if((FoundFlag && (
NameAllowed.Contains(
TrackVector.at(VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2171 (!FoundFlag && !InactiveFoundFlag))
2174 TrackLinkingRequiredFlag =
true;
2210 TrackLinkingRequiredFlag =
true;
2222 else if(FoundFlag || InactiveFoundFlag)
2242 bool BothPointFillets =
true;
2256 TrackLinkingRequiredFlag =
true;
2284 ShowMessage(
"Gaps must be set before track can be validated");
2293 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2304 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2322 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2329 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2354 std::pair<AnsiString, char>TempMapPair;
2362 TempMapPair.second =
'x';
2375 int NewHLoc, NewVLoc;
2376 bool ConnectionFoundFlag, LinkFoundFlag;
2378 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2380 for(
unsigned int y = 0; y < 4; y++)
2392 ConnectionFoundFlag =
false;
2393 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2399 ConnectionFoundFlag =
true;
2401 LinkFoundFlag =
false;
2402 for(
unsigned int a = 0; a < 4; a++)
2406 LinkFoundFlag =
true;
2421 if(!ConnectionFoundFlag)
2494 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2509 bool UnsetGaps =
false;
2516 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2520 for(
unsigned int y = 0; y < 4; y++)
2532 for(
unsigned int y = 0; y < 4; y++)
2542 for(
unsigned int y = 1; y < 4; y++)
2551 for(
unsigned int y = 0; y < 4; y++)
2564 for(
unsigned int y = 0; y < 4; y++)
2591 int NumberOfActiveElements = 0;
2593 GraphicsFollow =
false;
2597 if(MarkerString[MarkerString.Length()] ==
'1')
2599 GraphicsFollow =
true;
2601 for(
int x = 0; x < NumberOfActiveElements; x++)
2607 TrackElement.
HLoc = TempInt;
2609 TrackElement.
VLoc = TempInt;
2615 TrackElement.
Conn[0] = TempInt;
2635 if((TempInt != -1) && (TempInt < 10))
2641 if((TempInt != -1) && (TempInt < 10))
2654 if(Marker[1] ==
'3')
2658 else if(Marker[1] ==
'2')
2662 else if(Marker[1] ==
'G')
2674 int NumberOfInactiveElements = 0;
2678 for(
int x = 0; x < NumberOfInactiveElements; x++)
2684 TrackElement.
HLoc = TempInt;
2686 TrackElement.
VLoc = TempInt;
2692 bool LocError =
false;
2721 for(
int x = 0; x < NumberOfGraphics; x++)
2732 bool FileError =
false;
2734 for(
int x = 0; x < NumberOfGraphics; x++)
2747 UGME.second =
new TPicture;
2748 UGME.second->LoadFromFile(
UGME.first);
2751 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
2758 catch(
const EInvalidGraphic &e)
2767 delete UGMIt->second;
2772 catch(
const Exception &e)
2781 delete UGMIt->second;
2789 bool FoundInMap =
false;
2808 UGME.second =
new TPicture;
2809 UGME.second->LoadFromFile(
UGME.first);
2812 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
2819 catch(
const EInvalidGraphic &e)
2828 delete UGMIt->second;
2833 catch(
const Exception &e)
2842 delete UGMIt->second;
2867 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
2871 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
2873 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
2876 VecFile << x <<
'\n';
2877 VecFile << TrackElement.
SpeedTag <<
'\n';
2878 VecFile << TrackElement.
HLoc <<
'\n';
2879 VecFile << TrackElement.
VLoc <<
'\n';
2883 VecFile << TrackElement.
Conn[0] <<
'\n';
2887 VecFile << TrackElement.
Attribute <<
'\n';
2892 VecFile << int(1) <<
'\n';
2894 VecFile << int(0) <<
'\n';
2896 VecFile << TrackElement.
Length01 <<
'\n';
2897 VecFile << TrackElement.
Length23 <<
'\n';
2900 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
2907 VecFile <<
"3*****" <<
'\0' <<
'\n';
2911 VecFile <<
"2*****" <<
'\0' <<
'\n';
2915 VecFile <<
"G*****" <<
'\0' <<
'\n';
2919 VecFile <<
"4*****" <<
'\0' <<
'\n';
2924 VecFile <<
"******" <<
'\0' <<
'\n';
2929 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
2933 VecFile << x <<
'\n';
2934 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
2935 VecFile << InactiveTrackElement.
HLoc <<
'\n';
2936 VecFile << InactiveTrackElement.
VLoc <<
'\n';
2937 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
2938 VecFile <<
"******" <<
'\0' <<
'\n';
2953 GraphicsFollow =
false;
2955 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
2961 AnsiString MarkerString;
2968 if(MarkerString[MarkerString.Length()] ==
'1')
2970 GraphicsFollow =
true;
2972 for(
int x = 0; x < NumberOfActiveElements; x++)
2980 int SpeedTag = TempInt;
2987 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
2993 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
2998 if((SpeedTag > 87) && (SpeedTag < 96))
3001 if((TempInt < -1) || (TempInt > 3))
3007 if((TempInt < -1) || (TempInt > 999999))
3013 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3014 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3017 if((TempInt < -1) || (TempInt > 5))
3023 if((SpeedTag >= 68) && (SpeedTag <= 75))
3026 if((TempInt != 0) && (TempInt != 1))
3033 if((TempInt < -1) || (TempInt > 999999))
3039 if((TempInt < -1) || (TempInt > 999999))
3045 if((TempInt < -1) || (TempInt > 999999))
3051 if((TempInt < -1) || (TempInt > 999999))
3072 int NumberOfInactiveElements = 0;
3075 if(NumberOfInactiveElements < 0)
3085 for(
int x = 0; x < NumberOfInactiveElements; x++)
3099 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3105 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3132 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3138 AnsiString FileName =
"", TempStr =
"";
3140 for(
int x = 0; x < NumberOfGraphics; x++)
3142 TPicture *TempPicture =
new TPicture;
3151 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3164 catch(
const EInvalidGraphic &e)
3169 for(
int y = x + 1; y < NumberOfGraphics; y++)
3175 ShowMessage(FileName +
3176 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3181 catch(
const Exception &e)
3186 for(
int y = x + 1; y < NumberOfGraphics; y++)
3192 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3193 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3211 for(
int x = 0; x < VecSize; x++)
3234 for(
int x = 0; x < VecSize; x++)
3256 for(
int x = 0; x < VecSize; x++)
3310 for(
int x = 0; x < VecSize; x++)
3367 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3378 if(BothPointFilletsAndBasicLCs)
3453 Bitmap->Canvas->CopyMode = cmSrcCopy;
3455 Graphics::TBitmap *GraphicOutput;
3626 for(
int x = 0; x < 40; x++)
3645 Graphics::TBitmap *GraphicPtr;
3654 Graphics::TBitmap* SignalPlatformGraphic;
3687 if(OldTransparentColour !=
clB5G5R5)
3710 Bitmap->Canvas->CopyMode = cmSrcCopy;
3738 Bitmap->Canvas->CopyMode = cmSrcCopy;
3740 Graphics::TBitmap *GraphicOutput;
3750 if(BaseElement == 1)
3838 for(
int x = 0; x < 40; x++)
3857 Graphics::TBitmap *GraphicPtr;
3866 Graphics::TBitmap* SignalPlatformGraphic;
3927 for(
int x = 0; x < 40; x++)
3935 Graphics::TBitmap* SignalPlatformGraphic;
3956 if(OldTransparentColour !=
clB5G5R5)
3970 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4040 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4054 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4079 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4104 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4134 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4168 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4204 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4219 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4249 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4256 throw Exception(
"Error - Map & Vector different sizes");
4258 unsigned int NonZeroCount = 0;
4260 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4267 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4274 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4278 TrackMapEntry.first = TrackMapKeyPair;
4279 TrackMapEntry.second = x;
4280 if(!(
TrackMap.insert(TrackMapEntry).second))
4282 throw Exception(
"Error - map insertion failure, TrackVector in error");
4286 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4288 for(
unsigned int y = 0; y < 4; y++)
4313 THVPair GapMapKeyPair, GapMapValuePair;
4316 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4322 GapMapEntry.first = GapMapKeyPair;
4325 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4329 GapMapEntry.second = GapMapValuePair;
4332 GapMap.insert(GapMapEntry);
4345 bool CheckForLinks =
false;
4347 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4357 "Footbridge or underpass connection error. Each end must connect to a platform, concourse or other footbridge or underpass, and they can't connect to each other");
4365 for(
unsigned int y = 0; y < 4; y++)
4367 CheckForLinks =
false;
4379 bool ConnectionFoundFlag;
4383 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4389 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4396 if(ConnectionFoundFlag)
4400 bool LinkFoundFlag =
false;
4403 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4409 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4415 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
4423 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
4429 ShowMessage(
"Signal facing a bridge - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
4436 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
4439 CheckForLinks =
true;
4442 for(
unsigned int a = 0; a < 4; a++)
4451 LinkFoundFlag =
true;
4464 throw Exception(
"Error in final track linkage - invalid link");
4478 throw Exception(
"Error in final track linkage - connection not found");
4490 bool ConnErrorFlag =
false;
4492 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4495 ConnErrorFlag =
true;
4497 ConnErrorFlag =
true;
4499 ConnErrorFlag =
true;
4501 ConnErrorFlag =
true;
4504 if(
TrackVector.at(x).ActiveTrackElementName ==
"")
4506 if((
TrackVector.at(x).StationEntryStopLinkPos1 != -1) || (
TrackVector.at(x).StationEntryStopLinkPos2 != -1))
4508 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4517 throw Exception(
"ConnError in LinkTrack - Final");
4521 throw Exception(
"ConnError in LinkTrack - Precheck");
4525 bool CLkErrorFlag =
false;
4527 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4530 CLkErrorFlag =
true;
4532 CLkErrorFlag =
true;
4534 CLkErrorFlag =
true;
4536 CLkErrorFlag =
true;
4543 throw Exception(
"CLkError in LinkTrack - Final");
4547 throw Exception(
"CLkError in LinkTrack - Precheck");
4552 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4575 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4590 for(
unsigned int y = 0; y < 4; y++)
4603 bool ConnectionFoundFlag;
4609 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4616 if(ConnectionFoundFlag)
4619 bool LinkFoundFlag =
false;
4676 for(
unsigned int a = 0; a < 4; a++)
4685 LinkFoundFlag =
true;
4693 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
4703 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
4715 bool ConnErrorFlag =
false;
4717 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4720 ConnErrorFlag =
true;
4722 ConnErrorFlag =
true;
4724 ConnErrorFlag =
true;
4726 ConnErrorFlag =
true;
4729 if(
TrackVector.at(x).ActiveTrackElementName ==
"")
4731 if((
TrackVector.at(x).StationEntryStopLinkPos1 != -1) || (
TrackVector.at(x).StationEntryStopLinkPos2 != -1))
4733 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4742 throw Exception(
"ConnError in LinkTrack - Final");
4746 throw Exception(
"ConnError in LinkTrack - Precheck");
4750 bool CLkErrorFlag =
false;
4752 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4755 CLkErrorFlag =
true;
4757 CLkErrorFlag =
true;
4759 CLkErrorFlag =
true;
4761 CLkErrorFlag =
true;
4768 throw Exception(
"CLkError in LinkTrack - Final");
4772 throw Exception(
"CLkError in LinkTrack - Precheck");
4777 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4800 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4818 for(
unsigned int y = 0; y < 4; y++)
4831 bool ConnectionFoundFlag =
false;
4833 if(ConnectionFoundFlag)
4837 bool LinkFoundFlag =
false;
4857 for(
unsigned int a = 0; a < 4; a++)
4866 LinkFoundFlag =
true;
4886 bool ConnErrorFlag =
false;
4888 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4891 ConnErrorFlag =
true;
4893 ConnErrorFlag =
true;
4895 ConnErrorFlag =
true;
4897 ConnErrorFlag =
true;
4905 bool CLkErrorFlag =
false;
4907 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4910 CLkErrorFlag =
true;
4912 CLkErrorFlag =
true;
4914 CLkErrorFlag =
true;
4916 CLkErrorFlag =
true;
4933 int Position1, Position2;
4939 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
4941 int HLoc1 = GapMapPtr->first.first;
4942 int VLoc1 = GapMapPtr->first.second;
4943 int HLoc2 = GapMapPtr->second.first;
4944 int VLoc2 = GapMapPtr->second.second;
4947 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
4951 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
4955 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
4959 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
4977 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
4978 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
4988 bool FoundFlag =
false;
5000 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5001 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5002 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5023 bool FoundFlag =
false;
5036 TrackMapKeyPair.first = TrackElement.
HLoc;
5037 TrackMapKeyPair.second = TrackElement.
VLoc;
5038 TrackMapEntry.first = TrackMapKeyPair;
5043 LocationNameEntry.second = -(int)(
TrackVector.size());
5075 TrackMapKeyPair.first = HLoc;
5076 TrackMapKeyPair.second = VLoc;
5077 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5087 return TrackMapPtr->second;
5100 TrackMapKeyPair.first = HLoc;
5101 TrackMapKeyPair.second = VLoc;
5102 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5105 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5106 throw Exception(Message);
5121 THVPair InactiveTrackMapKeyPair;
5124 InactiveTrackMapKeyPair.first = HLoc;
5125 InactiveTrackMapKeyPair.second = VLoc;
5129 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5130 throw Exception(Message);
5144 bool Present =
true;
5148 TrackMapKeyPair.first = HLoc;
5149 TrackMapKeyPair.second = VLoc;
5150 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5165 bool Present =
true;
5166 THVPair InactiveTrackMapKeyPair;
5169 InactiveTrackMapKeyPair.first = HLoc;
5170 InactiveTrackMapKeyPair.second = VLoc;
5188 THVPair InactiveTrackMapKeyPair;
5193 InactiveTrackMapKeyPair.first = HLoc;
5194 InactiveTrackMapKeyPair.second = VLoc;
5203 if(InactiveTrackRange.first == InactiveTrackRange.second)
5212 RetPair.first = InactiveTrackRange.first->second;
5213 RetPair.second = (--InactiveTrackRange.second)->second;
5226 AnsiString(DivergingPosition));
5237 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
5238 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
5239 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
5240 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
5241 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
5242 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
5243 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
5244 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
5245 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
5246 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
5247 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
5248 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
5282 throw Exception(
"Error, Wrong track type in PlotGap");
5284 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
5288 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
5292 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
5296 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
5300 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
5304 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
5308 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
5312 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
5316 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
5320 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
5324 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
5328 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
5332 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
5336 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
5340 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
5344 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
5358 throw Exception(
"Error, Wrong track type in PlotPoints");
5369 else if(TrackElement.
SpeedTag < 132)
5387 else if(TrackElement.
SpeedTag < 132)
5419 throw Exception(
"Error, Wrong track type in PlotSignal");
5421 for(
int x = 0; x < 40; x++)
5492 for(
int x = 0; x < 40; x++)
5499 Graphics::TBitmap* SignalPlatformGraphic;
5586 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
5594 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
5602 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
5610 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
5626 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
5634 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
5642 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
5650 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
5682 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
5694 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
5706 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
5718 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
5760 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
5762 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
5764 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
5767 if(BaseElementSpeedTag == 1)
5771 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
5778 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
5786 Graphics::TBitmap *RouteGraphic;
5788 if(TypeOfRoute == 1)
5792 else if(TypeOfRoute == 0)
5798 RouteGraphic = BaseGraphic;
5805 if(UpStep == DownStep)
5808 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
5818 else if((DownStep - UpStep) == 1)
5823 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
5833 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5846 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5856 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
5872 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
5882 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5892 else if(DownStep == 0)
5895 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5905 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
5918 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5928 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5938 for(
int x = (UpStep + 1); x < DownStep; x++)
5942 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
5944 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
5964 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
5971 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
5977 Graphics::TBitmap *RouteGraphic;
5979 if(TypeOfRoute == 1)
5983 else if(TypeOfRoute == 0)
5989 RouteGraphic = BaseGraphic;
5998 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6008 else if((RStep - LStep) == 1)
6013 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6023 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6036 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6046 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6062 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6072 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6085 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6095 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6108 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6118 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6128 for(
int x = (LStep + 1); x < RStep; x++)
6133 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6137 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
6161 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6164 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6166 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6168 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6171 if(BaseElementSpeedTag == 1)
6175 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
6182 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
6188 if(UpStep == DownStep)
6199 else if((DownStep - UpStep) == 1)
6218 for(
int x = (UpStep + 1); x < DownStep; x++)
6227 for(
int x = (UpStep + 1); x < DownStep; x++)
6234 for(
int x = UpStep; x <= DownStep; x++)
6247 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
6254 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
6271 else if((RStep - LStep) == 1)
6290 for(
int x = (LStep + 1); x < RStep; x++)
6299 for(
int x = (LStep + 1); x < RStep; x++)
6306 for(
int x = LStep; x <= RStep; x++)
6325 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
6327 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6329 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
6332 if(BaseElementSpeedTag == 1)
6336 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
6343 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
6349 for(
int x = UpStep; x < (DownStep + 1); x++)
6364 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
6371 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
6377 for(
int x = LStep; x < (RStep + 1); x++)
6396 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6399 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6401 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6403 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6408 if(BaseElementSpeedTag == 1)
6412 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
6419 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
6425 for(
int x = UpStep; x <= DownStep; x++)
6439 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
6446 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
6452 for(
int x = LStep; x <= RStep; x++)
6468 Graphics::TBitmap *RouteGraphic;
6471 if(BaseElementSpeedTag == 1)
6473 if(TypeOfRoute == 1)
6477 else if(TypeOfRoute == 0)
6483 RouteGraphic = BaseGraphic;
6487 RouteGraphic = BaseGraphic;
6492 if(TypeOfRoute == 1)
6496 else if(TypeOfRoute == 0)
6502 RouteGraphic = BaseGraphic;
6505 RouteGraphic = BaseGraphic;
6509 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
6513 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6515 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6521 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
6524 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6529 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
6533 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
6535 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
6541 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
6544 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
6669 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
6673 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
6704 "," + AnsiString(VLoc));
6708 int DummyRouteNumber;
6710 TrainPresent =
false;
6714 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
6716 TrackMapKeyPair.first = HLoc;
6717 TrackMapKeyPair.second = VLoc + UpStep;
6718 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6727 TrainPresent =
true;
6736 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
6738 TrackMapKeyPair.first = HLoc;
6739 TrackMapKeyPair.second = VLoc + DownStep;
6740 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6749 TrainPresent =
true;
6758 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
6760 TrackMapKeyPair.first = HLoc + LeftStep;
6761 TrackMapKeyPair.second = VLoc;
6762 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6771 TrainPresent =
true;
6780 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
6782 TrackMapKeyPair.first = HLoc + RightStep;
6783 TrackMapKeyPair.second = VLoc;
6784 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6793 TrainPresent =
true;
6810 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
6817 else if(TrackElement.
SpeedTag < 132)
6835 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
6852 AnsiString(ScreenPosV));
6867 AnsiString(ScreenPosV));
6878 AnsiString(VPosTrue));
6892 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
6904 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
6905 " in TrackMap, Caller=" + (AnsiString)Caller);
6907 if(MapVecPos != (
int)a)
6909 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
6910 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
6911 (AnsiString)Caller);
6917 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
6918 " Caller=" + (AnsiString)Caller);
6938 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
6939 " in InactiveMap, Caller=" + (AnsiString)Caller);
6941 if((InactivePair.first != a) && (InactivePair.second != a))
6943 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
6944 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
6945 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
6950 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
6951 " Caller=" + (AnsiString)Caller);
6961 int Position1, Position2;
6967 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
6969 int HLoc1 = GapMapPtr->first.first;
6970 int VLoc1 = GapMapPtr->first.second;
6971 int HLoc2 = GapMapPtr->second.first;
6972 int VLoc2 = GapMapPtr->second.second;
6975 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
6979 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
6983 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
6987 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
6991 unsigned int GapCount = 0;
6993 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
6999 if((
GapMap.size() * 2) != GapCount)
7001 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7002 (AnsiString)Caller);
7012 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7016 throw Exception(
"Error - TrackFinished with erase element still present");
7021 AnsiString IDString;
7023 if(TrackElement.
HLoc < 0)
7024 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7026 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7027 if(TrackElement.
VLoc < 0)
7028 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7030 IDString += AnsiString(TrackElement.
VLoc);
7043 for(
int x = 1; x < String.Length() + 1; x++)
7045 if(String.IsDelimiter(
"-", x))
7050 if(x == String.Length())
7053 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
7061 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
7065 if(DelimPos == String.Length())
7068 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
7072 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
7075 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
7081 if(String.SubString(1, 1) !=
"N")
7083 for(
int x = 1; x < DelimPos; x++)
7085 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7088 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7094 if(String.SubString(1, 1) ==
"N")
7096 for(
int x = 2; x < DelimPos; x++)
7098 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7101 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7107 if(String.SubString(1, 1) ==
"N")
7108 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
7110 HLoc = String.SubString(1, DelimPos - 1).ToInt();
7112 if(String.SubString(DelimPos + 1, 1) !=
"N")
7114 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
7116 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7119 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7125 if(String.SubString(DelimPos + 1, 1) ==
"N")
7127 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
7129 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7132 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7138 if(String.SubString(DelimPos + 1, 1) ==
"N")
7139 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
7141 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
7146 TrackMapPtr =
TrackMap.find(HVPair);
7150 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
7155 return TrackMapPtr->second;
7166 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
7167 int HLoc = TrackElement.
HLoc;
7168 int VLoc = TrackElement.
VLoc;
7271 AnsiString(SpeedTag));
7282 if(HVRange.first == HVRange.second)
7288 HVIt1 = HVRange.first;
7292 if(--HVRange.second != HVRange.first)
7294 HVIt2 = HVRange.second;
7298 HVIt2->second).
SpeedTag == SpeedTag)))
7318 AnsiString(SpeedTag));
7384 AnsiString TestString1, TestString2;
7389 throw Exception(
"LNPendingList size not 1 on entry");
7391 int CurrentElementNumber;
7397 int H = CurrentElement->HLoc;
7398 int V = CurrentElement->VLoc;
7399 int Tag = CurrentElement->SpeedTag;
7405 for(
int x = 0; x < 25; x++)
7415 for(
int x = 0; x < 25; x++)
7425 for(
int x = 0; x < 25; x++)
7435 for(
int x = 0; x < 25; x++)
7445 for(
int x = 0; x < 28; x++)
7455 for(
int x = 0; x < 8; x++)
7465 for(
int x = 0; x < 8; x++)
7475 for(
int x = 0; x < 4; x++)
7485 for(
int x = 0; x < 8; x++)
7495 for(
int x = 0; x < 8; x++)
7508 if(CurrentElementNumber > -1)
7513 if((ExistingName !=
"") && (ExistingName != LocationName))
7527 AddName(1, CurrentElement, LocationName);
7531 LNDone2MultiMapEntry.first = HVPair;
7542 bool FoundFlag, ErasedFlag =
false;
7544 if(SNRange.first != SNRange.second)
7548 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
7555 TVIt->LocationName =
"";
7556 TVIt->ActiveTrackElementName =
"";
7585 std::pair<AnsiString, char>TempMapPair;
7593 TempMapPair.second =
'x';
7611 AnsiString(SpeedTag));
7621 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
7628 int MapPos = -1 - Position;
7632 FoundElement = MapPos;
7648 FoundElement = IMPair.first;
7657 FoundElement = IMPair.second;
7678 AnsiString OldName = TrackElement->LocationName, ErrorString;
7680 TrackElement->LocationName = Name;
7681 int HLoc = TrackElement->HLoc;
7682 int VLoc = TrackElement->VLoc;
7696 if(ErrorString !=
"")
7698 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
7722 if(LNDone2MultiMapIterator->second == MapPos)
7749 if(*LNPendingListIterator == MapPos)
7822 if(NameBeingChecked !=
"")
7828 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
7836 NameBeingChecked = LNMMRg.second->first;
7838 if(NameBeingChecked !=
"")
7844 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
7865 if(LNMMIt->second < 0)
7875 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
7883 std::list<THVPair> HVLinkedList;
7886 HVPairsLinkedMap.begin()->second =
true;
7887 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
7890 THVPair HVPairUnderExamination;
7891 THVPairsLinkedMap::iterator HVPLMIt;
7893 while(!HVLinkedList.empty())
7895 HVPairUnderExamination = HVLinkedList.front();
7896 HVLinkedList.pop_front();
7897 HVPairNew.first = HVPairUnderExamination.first;
7898 HVPairNew.second = HVPairUnderExamination.second - 1;
7899 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7900 if(HVPLMIt != HVPairsLinkedMap.end())
7902 if(!HVPLMIt->second)
7904 HVLinkedList.push_back(HVPLMIt->first);
7906 HVPLMIt->second =
true;
7908 HVPairNew.first = HVPairUnderExamination.first - 1;
7909 HVPairNew.second = HVPairUnderExamination.second;
7910 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7911 if(HVPLMIt != HVPairsLinkedMap.end())
7913 if(!HVPLMIt->second)
7915 HVLinkedList.push_back(HVPLMIt->first);
7917 HVPLMIt->second =
true;
7919 HVPairNew.first = HVPairUnderExamination.first;
7920 HVPairNew.second = HVPairUnderExamination.second + 1;
7921 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7922 if(HVPLMIt != HVPairsLinkedMap.end())
7924 if(!HVPLMIt->second)
7926 HVLinkedList.push_back(HVPLMIt->first);
7928 HVPLMIt->second =
true;
7930 HVPairNew.first = HVPairUnderExamination.first + 1;
7931 HVPairNew.second = HVPairUnderExamination.second;
7932 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
7933 if(HVPLMIt != HVPairsLinkedMap.end())
7935 if(!HVPLMIt->second)
7937 HVLinkedList.push_back(HVPLMIt->first);
7939 HVPLMIt->second =
true;
7944 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
7946 if(!HVPLMIt->second)
7965 if(LocationName ==
"")
7976 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7981 ActiveTrackElementNameMapEntry.first =
Track->
TrackVector.at(x).ActiveTrackElementName;
7982 ActiveTrackElementNameMapEntry.second = 0;
8004 bool FoundFlag, ErasedFlag =
false;
8008 if(SNRange.first != SNRange.second)
8011 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8014 TVIt->LocationName =
"";
8015 TVIt->ActiveTrackElementName =
"";
8047 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
8049 AnsiString LocationName;
8058 if(LocationName !=
"")
8066 if(LocationName !=
"")
8080 if(LocationName !=
"")
8082 int ModifiedPosition = -1 - Position;
8092 for(
int x = 0; x < 25; x++)
8102 else if(SpeedTag == 77)
8104 for(
int x = 0; x < 25; x++)
8114 else if(SpeedTag == 78)
8116 for(
int x = 0; x < 25; x++)
8126 else if(SpeedTag == 79)
8128 for(
int x = 0; x < 25; x++)
8138 else if(SpeedTag == 96)
8140 for(
int x = 0; x < 28; x++)
8150 else if(SpeedTag == 129)
8152 for(
int x = 0; x < 8; x++)
8162 else if(SpeedTag == 130)
8164 for(
int x = 0; x < 8; x++)
8174 else if(SpeedTag == 145)
8176 for(
int x = 0; x < 8; x++)
8186 else if(SpeedTag == 146)
8188 for(
int x = 0; x < 8; x++)
8198 else if(SpeedTag == 131)
8200 for(
int x = 0; x < 4; x++)
8223 AnsiString(SpeedTag));
8235 if(TempElement->LocationName !=
"")
8237 LocationName = TempElement->LocationName;
8238 FoundElement = IMPair.first;
8246 if(TempElement->LocationName !=
"")
8248 LocationName = TempElement->LocationName;
8249 FoundElement = IMPair.second;
8262 if(TempElement->LocationName !=
"")
8264 LocationName = TempElement->LocationName;
8265 FoundElement = -1 - Position;
8281 unsigned int Count = 0;
8289 AnsiString SName, TName, ErrorString;
8291 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8297 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
8298 AnsiString(Caller));
8311 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
8312 AnsiString(Caller));
8319 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
8320 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8326 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8332 if(ErrorString !=
"")
8334 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
8336 if(SNIt->second != -1 - (
int)x)
8338 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8339 AnsiString(Caller));
8345 bool FoundFlag =
false;
8354 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackVector.at(x).HLoc) +
" & V " +
8355 AnsiString(
TrackVector.at(x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8359 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackVector.at(x).HLoc) +
8360 " & V " + AnsiString(
TrackVector.at(x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
8361 AnsiString(Caller));
8366 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackVector.at(x).HLoc) +
" & V " +
8367 AnsiString(
TrackVector.at(x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8377 if(ErrorString !=
"")
8379 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
8381 if(SNIt->second != (
int)x)
8383 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8384 AnsiString(Caller));
8394 AnsiString &ErrorString)
8402 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
8404 bool FoundFlag =
false;
8408 if(SNRange.first == SNRange.second)
8410 ErrorString =
"Error, Name " + LocationName +
" not found in map";
8412 return SNRange.first;
8416 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8418 if(SNIterator->second < 0)
8420 int TVPos = -1 - SNIterator->second;
8422 if(TVIt == TrackElement)
8431 int ITVPos = SNIterator->second;
8433 if(ITVIt == TrackElement)
8443 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
8459 LocationNameEntry.first = NewName;
8460 LocationNameEntry.second = SNIterator->second;
8474 int TruePos = -1 - Position;
8478 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
8488 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
8511 InactiveTrack2MultiMapIterator++)
8513 if(InactiveTrack2MultiMapIterator->second > VecPos)
8514 InactiveTrack2MultiMapIterator->second--;
8521 LocationNameMultiMapIterator++)
8523 if(LocationNameMultiMapIterator->second < 0)
8525 if(LocationNameMultiMapIterator->second > (
int)VecPos)
8526 LocationNameMultiMapIterator->second--;
8547 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
8549 if(TrackMapIterator->second > VecPos)
8550 TrackMapIterator->second--;
8557 LocationNameMultiMapIterator++)
8559 if(LocationNameMultiMapIterator->second >= 0)
8563 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
8564 LocationNameMultiMapIterator->second++;
8567 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8573 if(TkEl.
Conn[0] ==
int(VecPos))
8578 if(TkEl.
Conn[0] >
int(VecPos))
8580 if(TkEl.
Conn[0] > -1)
8604 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
8610 LocationNameEntry.second = -1 - TVPos;
8621 LocationNameEntry.second = ITVPos;
8663 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8695 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8719 AnsiString((
short)FirstTrack));
8720 bool LengthDifferent =
false, SpeedDifferent =
false;
8728 int EXArray[16][2] =
8730 {2, 4}, {6, 2}, {8, 6}, {4, 8},
8731 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
8734 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
8735 Graphics::TBitmap *Bitmap;
8739 InLink = TrackElement.
Link[0];
8740 OutLink = TrackElement.
Link[1];
8744 InLink = TrackElement.
Link[2];
8745 OutLink = TrackElement.
Link[3];
8748 for(
int x = 0; x < 16; x++)
8750 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
8755 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
8773 else if(TrackElement.
SpeedTag == 54)
8775 else if(TrackElement.
SpeedTag == 55)
8782 else if(TrackElement.
SpeedTag == 58)
8784 else if(TrackElement.
SpeedTag == 59)
8787 else if(Index == 14)
8791 else if(TrackElement.
SpeedTag == 52)
8793 else if(TrackElement.
SpeedTag == 57)
8796 else if(Index == 15)
8800 else if(TrackElement.
SpeedTag == 53)
8802 else if(TrackElement.
SpeedTag == 56)
8812 if(LengthDifferent && SpeedDifferent)
8853 else if(LengthDifferent && !SpeedDifferent)
8947 AnsiString((
short)FirstTrack));
8948 LengthDifferent =
false;
8949 SpeedDifferent =
false;
8954 LengthDifferent =
true;
8958 SpeedDifferent =
true;
8960 if(LengthDifferent || SpeedDifferent)
8973 LengthDifferent =
true;
8977 SpeedDifferent =
true;
8979 if(LengthDifferent || SpeedDifferent)
8992 LengthDifferent =
true;
8996 SpeedDifferent =
true;
8998 if(LengthDifferent || SpeedDifferent)
9078 AnsiString TempName;
9079 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
9080 bool ForwardSet, ReverseSet;
9082 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9087 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9125 for(
int y = 0; y < 2; y++)
9156 StartElement = TempElement;
9157 StartVecPos = VecPos;
9161 StartEntryPos = 1 - Dir;
9170 VecPos = TempElement.
Conn[1 - EntryPos];
9171 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9173 EntryPos = TempEntryPos;
9201 ForwardNumber = ((Count + 1) / 2) + 1;
9202 ReverseNumber = (Count - ForwardNumber) + 1;
9205 TempElement = StartElement;
9206 VecPos = StartVecPos;
9207 if(Count == ForwardNumber)
9212 if(Count == ReverseNumber)
9220 VecPos = TempElement.
Conn[1 - EntryPos];
9221 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9223 EntryPos = TempEntryPos;
9225 if(Count == ForwardNumber)
9230 if(Count == ReverseNumber)
9242 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9244 if(
TrackVector.at(x).StationEntryStopLinkPos1 == 5)
9248 if(
TrackVector.at(x).StationEntryStopLinkPos2 == 5)
9356 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9392 if((TextH / 16) - 1 <
HLocMin)
9394 if((TextH / 16) + 1 >
HLocMax)
9396 if((TextV / 16) - 1 <
VLocMin)
9398 if((TextV / 16) + 1 >
VLocMax)
9418 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
9419 bool &UserGraphicFoundFlag)
9422 TUserGraphicVector::iterator UserGraphicPtr;
9424 UserGraphicFoundFlag =
false;
9431 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
9432 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
9434 UserGraphicItem = x;
9435 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
9436 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
9437 UserGraphicFoundFlag =
true;
9453 int SpeedTag = TrackElement.
SpeedTag;
9457 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
9506 return GraphicOutput;
9514 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
9516 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
9529 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
9530 " in InactiveTrackElementAt");
9541 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
9543 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
9568 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
9569 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
9573 if(SNRange.first == SNRange.second)
9578 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9580 if(SNIterator->second < 0)
9586 HVPair.first = InactiveElement.
HLoc;
9587 HVPair.second = InactiveElement.
VLoc;
9591 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
9593 int TVPos =
TrackMap.find(HVPair)->second;
9596 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
9602 FirstNamedExitPos = 0;
9606 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9607 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9610 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9612 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
9613 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9614 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9617 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9627 FirstNamedExitPos = 1;
9631 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9632 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9635 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9637 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
9638 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9639 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9642 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9657 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
9671 AnsiString(FirstNamedElementPos));
9672 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
9673 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
9675 SecondNamedElementPos = -1;
9676 FirstNamedLinkedElementPos = -1;
9677 SecondNamedLinkedElementPos = -1;
9681 if(SNRange.first == SNRange.second)
9686 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9688 if(SNIterator->second < 0)
9694 HVPair.first = InactiveElement.
HLoc;
9695 HVPair.second = InactiveElement.
VLoc;
9707 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
9711 int TVPos =
TrackMap.find(HVPair)->second;
9712 if(TVPos != FirstNamedElementPos)
9716 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
9722 FirstNamedExitPos = 0;
9726 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9727 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9730 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9732 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
9733 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9734 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9737 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9739 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
9740 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
9741 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
9750 FirstNamedExitPos = 1;
9754 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9755 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9758 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9760 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
9761 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9762 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9765 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9767 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
9768 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
9769 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
9789 if(SNRange.first != SNRange.second)
9791 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9793 if(SNIterator->second < 0)
9813 "," + AnsiString(SpeedTag));
9824 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
9850 else if(SpeedTag == 69)
9872 else if(SpeedTag == 70)
9894 else if(SpeedTag == 71)
9927 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
9928 if(NextEntryPos < 0)
9941 if(NextEntryPos > 1)
9960 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
9972 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
9973 bool FoundFlag =
false;
9988 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
9989 bool FoundFlag =
false;
10008 VPosHi = 16 * VLocHi;
10009 VPosLo = 16 * VLocLo;
10028 AnsiString(EndTVPosition));
10039 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
10040 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
10041 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
10042 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
10044 if(Link0Squares <= Link1Squares)
10061 AnsiString(LinkPos));
10080 if((LinkPos == 1) && (TE.
Attribute == 0))
10085 else if(LinkPos == 1)
10091 else if((LinkPos == 3) && (TE.
Attribute == 1))
10096 else if(LinkPos == 3)
10103 else if(LinkPos == 0)
10108 else if(LinkPos == 1)
10113 else if(LinkPos == 2)
10118 else if(LinkPos == 3)
10123 throw Exception(
"Error, failure in GetExitPos");
10172 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
10176 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
10216 "," + AnsiString(DiagonalLinkNumber));
10221 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
10227 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
10233 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
10239 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
10256 AnsiString JustFileName =
"";
10261 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
10268 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
10287 typedef std::list<int> TNamePosList;
10288 TNamePosList NamePosList;
10289 typedef TNamePosList::iterator TNPLIt;
10291 typedef std::list<int> TOnePlatList;
10292 TOnePlatList OnePlatList;
10293 typedef TOnePlatList::iterator TOPLIt;
10296 NamePosList.clear();
10297 OnePlatList.clear();
10298 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10300 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
10302 NamePosList.push_back(x);
10307 if(!NamePosList.empty())
10309 OnePlatList.push_back(NamePosList.back());
10310 NamePosList.pop_back();
10313 while(!OnePlatList.empty())
10315 TempInt = OnePlatList.front();
10318 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
10319 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
10321 OnePlatList.push_back(TempElement.
Conn[0]);
10322 NamePosList.erase(NPLIt);
10324 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
10325 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
10327 OnePlatList.push_back(TempElement.
Conn[1]);
10328 NamePosList.erase(NPLIt);
10331 OnePlatList.erase(OnePlatList.begin());
10332 if(OnePlatList.empty())
10335 if(!NamePosList.empty())
10337 OnePlatList.push_back(NamePosList.back());
10338 NamePosList.pop_back();
10355 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
10370 throw Exception(
"Return value negative in call to LastElementNumber");
10382 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
10396 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
10408 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
10409 " in GetModifiablePrefDirElementAt");
10419 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
10421 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
10431 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
10433 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
10450 int TrackVectorPosition;
10502 FinishElement =
false;
10503 int TrackVectorPosition;
10526 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
10537 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
10560 for(
int x = 0; x < 4; x++)
10583 FinishElement =
true;
10591 for(
int x = 0; x < 4; x++)
10603 FinishElement =
true;
10611 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10618 .ELinkPos] ==
Lead))
10634 FinishElement =
true;
10653 FinishElement =
true;
10672 FinishElement =
true;
10687 FinishElement =
true;
10696 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10712 FinishElement =
true;
10718 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10741 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
10742 int VectorCount = 0;
10746 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
10748 for(
int x = 0; x < VectorCount; x++)
10753 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
10757 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
10758 SearchElement.
ELinkPos = NextELinkPos;
10771 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
10773 SearchElement.
XLinkPos = NextXLinkPos;
10799 for(
int x = 0; x < VectorCount; x++)
10809 for(
int x = 0; x < VectorCount; x++)
10821 for(
int x = 0; x < VectorCount; x++)
10833 for(
int x = 0; x < VectorCount; x++)
10842 for(
int x = 0; x < VectorCount; x++)
10851 SearchElement.
XLink = SearchElement.
Link[1];
10870 SearchElement.
XLink = SearchElement.
Link[3];
10883 for(
int x = 0; x < VectorCount; x++)
10895 XLinkPos = NextXLinkPos;
10896 CurrentTrackElement = SearchElement;
10915 throw Exception(
"Error, SearchVector empty");
10922 for(
int x = 0; x < 4; x++)
10967 throw Exception(
"Error in EntryExitNumber 1");
10987 if(PrefDirElement.
XLink == -1)
10995 if(PrefDirElement.
XLink != -1)
10999 throw Exception(
"Error in EntryExitNumber 2");
11035 LeadingPoints =
false;
11063 LeadingPoints =
true;
11079 AnsiString ErrorString;
11080 bool Error =
false;
11087 ErrorString =
"HLoc";
11093 ErrorString =
"VLoc";
11099 ErrorString =
"ELink";
11105 ErrorString =
"ELinkPos";
11111 ErrorString =
"XLink";
11117 ErrorString =
"XLinkPos";
11123 ErrorString =
"Tag";
11129 ErrorString =
"TrackVectorPosition";
11135 ErrorString =
"EXNumber";
11142 ErrorString =
"CheckCount";
11149 ErrorString =
"EntryGraphicPtr";
11155 ErrorString =
"EntryDirectionGraphicPtr";
11164 ErrorString =
"Last XLink not connected to this element";
11171 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
11195 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
11252 AnsiString((
short)BuildingPrefDir));
11255 if(PrefDirSize() == 0)
11260 for(
unsigned int x = 0; x < PrefDirSize(); x++)
11272 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
11284 if(x == (PrefDirSize() - 1))
11293 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
11295 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
11296 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
11297 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
11299 if(PrefDirSize() > 1)
11301 unsigned int LatestPos = PrefDirSize() - 1;
11302 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
11303 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
11304 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
11326 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
11329 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
11333 H = MMIT->first.first;
11334 V = MMIT->first.second;
11337 if(PrefDirPos0 > -1)
11339 if(PrefDirPos1 > -1)
11341 if(PrefDirPos2 > -1)
11343 if(PrefDirPos3 > -1)
11345 if(PrefDirPos3 > -1)
11360 else if(PrefDirPos2 > -1)
11399 else if(PrefDirPos1 > -1)
11420 else if(PrefDirPos0 > -1)
11439 int NumberOfPrefDirElements = 0;
11442 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11444 VecFile >> TempInt;
11447 VecFile >> TempInt;
11448 LoadPrefDirElement.
ELink = TempInt;
11449 VecFile >> TempInt;
11450 LoadPrefDirElement.
ELinkPos = TempInt;
11451 VecFile >> TempInt;
11452 LoadPrefDirElement.
XLink = TempInt;
11453 VecFile >> TempInt;
11454 LoadPrefDirElement.
XLinkPos = TempInt;
11455 VecFile >> TempInt;
11456 LoadPrefDirElement.
EXNumber = TempInt;
11457 VecFile >> TempInt;
11462 if(!(LoadPrefDirElement.
IsARoute))
11488 int NumberOfPrefDirElements = 0;
11491 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11493 VecFile >> TempInt;
11494 VecFile >> TempInt;
11497 VecFile >> TempInt;
11498 LoadPrefDirElement.
ELink = TempInt;
11499 VecFile >> TempInt;
11500 LoadPrefDirElement.
ELinkPos = TempInt;
11501 VecFile >> TempInt;
11502 LoadPrefDirElement.
XLink = TempInt;
11503 VecFile >> TempInt;
11504 LoadPrefDirElement.
XLinkPos = TempInt;
11505 VecFile >> TempInt;
11506 LoadPrefDirElement.
EXNumber = TempInt;
11507 VecFile >> TempInt;
11512 if(!(LoadPrefDirElement.
IsARoute))
11540 int NumberOfPrefDirElements = 0;
11543 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
11548 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11555 VecFile >> TempInt;
11556 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
11561 VecFile >> TempInt;
11562 if((TempInt < -1) || (TempInt > 9))
11567 VecFile >> TempInt;
11568 if((TempInt < -1) || (TempInt > 3))
11573 VecFile >> TempInt;
11574 if((TempInt < -1) || (TempInt > 9))
11579 VecFile >> TempInt;
11580 if((TempInt < -1) || (TempInt > 3))
11585 VecFile >> TempInt;
11586 if((TempInt < -1) || (TempInt > 27))
11591 VecFile >> TempInt;
11599 VecFile >> TempInt;
11600 if((TempInt != 0) && (TempInt != 1))
11605 VecFile >> TempInt;
11606 if((TempInt != 0) && (TempInt != 1))
11611 VecFile >> TempInt;
11612 if((TempInt != 0) && (TempInt != 1))
11635 for(
int y = 0; y < NumberOfPrefDirElements; y++)
11637 VecFile << y <<
'\n';
11638 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
11648 if(y == (NumberOfPrefDirElements - 1))
11650 VecFile <<
"************" <<
'\0' <<
'\n';
11654 VecFile <<
"******" <<
'\0' <<
'\n';
11668 for(
int y = 0; y < NumberOfSearchElements; y++)
11670 VecFile << y <<
'\n';
11671 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
11681 if(y == (NumberOfSearchElements - 1))
11683 VecFile <<
"************" <<
'\0' <<
'\n';
11687 VecFile <<
"******" <<
'\0' <<
'\n';
11792 bool AlreadyPresent, FoundFlag;
11793 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
11795 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
11799 AlreadyPresent =
false;
11803 AlreadyPresent =
true;
11805 AlreadyPresent =
true;
11807 AlreadyPresent =
true;
11809 AlreadyPresent =
true;
11811 if(!AlreadyPresent)
11856 for(
unsigned int z = 0; z < 4; z++)
11864 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
11878 bool DiscrepancyFound =
false;
11888 DiscrepancyFound =
true;
11891 DiscrepancyFound =
true;
11896 DiscrepancyFound =
true;
11901 DiscrepancyFound =
true;
11906 DiscrepancyFound =
true;
11911 DiscrepancyFound =
true;
11913 if(DiscrepancyFound)
11915 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
11930 bool DiscrepancyFound =
false;
11940 DiscrepancyFound =
true;
11943 DiscrepancyFound =
true;
11948 DiscrepancyFound =
true;
11953 DiscrepancyFound =
true;
11958 DiscrepancyFound =
true;
11963 DiscrepancyFound =
true;
11966 return !DiscrepancyFound;
11978 bool FoundFlag =
false;
11979 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
11987 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
11988 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
11990 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
11992 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
11993 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
11994 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
11999 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
12000 +
" Caller=" + (AnsiString)Caller);
12026 PrefDirMapKeyPair.first = HLoc;
12027 PrefDirMapKeyPair.second = VLoc;
12028 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12031 if(ItPair.first == ItPair.second)
12039 PrefDirPos0 = ItPair.first->second;
12041 if(ItPair.first == ItPair.second)
12046 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12047 PrefDirPos1 = ItPair.first->second;
12049 if(ItPair.first == ItPair.second)
12054 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12055 PrefDirPos2 = ItPair.first->second;
12057 if(ItPair.first == ItPair.second)
12062 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12063 PrefDirPos3 = ItPair.first->second;
12077 THVPair PrefDir4MultiMapKeyPair;
12080 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
12081 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
12082 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
12105 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
12124 AnsiString(ErasedElementNumber));
12129 if(MapPtr->second > ErasedElementNumber)
12149 throw Exception(
"PrefDirVectorPosition out of range");
12152 THVPair PrefDir4MultiMapKeyPair;
12154 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
12155 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
12156 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12159 if(ItPair.first == ItPair.second)
12162 return ItPair.first;
12166 if(ItPair.first->second == PrefDirVectorPosition)
12170 return ItPair.first;
12173 if(ItPair.first == ItPair.second)
12176 return ItPair.first;
12178 if(ItPair.first->second == PrefDirVectorPosition)
12182 return ItPair.first;
12185 if(ItPair.first == ItPair.second)
12188 return ItPair.first;
12190 if(ItPair.first->second == PrefDirVectorPosition)
12194 return ItPair.first;
12197 if(ItPair.first == ItPair.second)
12200 return ItPair.first;
12202 if(ItPair.first->second == PrefDirVectorPosition)
12206 return ItPair.first;
12210 return ItPair.first;
12223 THVPair PrefDir4MultiMapKeyPair;
12225 PrefDir4MultiMapKeyPair.first = HLoc;
12226 PrefDir4MultiMapKeyPair.second = VLoc;
12227 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12230 if(ItPair.first == ItPair.second)
12238 return ItPair.first->second;
12247 bool ErasedFlag =
false;
12249 if(ErasedTrackVectorPosition > -1)
12258 ErasedFlag =
false;
12260 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
12265 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
12270 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
12275 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
12280 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
12288 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
12292 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
12296 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
12300 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
12304 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
12319 OverallDistance = 0;
12320 OverallSpeedLimit = 0;
12321 LeadingPointsAtLastElement =
false;
12330 LeadingPointsAtLastElement =
true;
12339 OverallDistance += PrefDirElement.
Length23;
12340 if(OverallSpeedLimit != -1)
12350 OverallSpeedLimit = -1;
12357 OverallDistance += PrefDirElement.
Length01;
12358 if(OverallSpeedLimit != -1)
12368 OverallSpeedLimit = -1;
12388 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12391 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12395 HLoc = MMIT->first.first;
12396 VLoc = MMIT->first.second;
12401 if(PrefDirPos0 > -1)
12403 if(PrefDirPos1 > -1)
12405 if(PrefDirPos2 > -1)
12407 if(PrefDirPos3 > -1)
12409 if(PrefDirPos3 > -1)
12411 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12413 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12415 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12417 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
12424 else if(PrefDirPos2 > -1)
12428 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12430 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12432 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
12440 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12442 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12444 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
12452 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12454 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12456 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12463 else if(PrefDirPos1 > -1)
12467 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12469 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12476 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12478 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
12484 else if(PrefDirPos0 > -1)
12486 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12503 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12506 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12527 if(PrefDirPos0 > -1)
12529 if(PrefDirPos1 > -1)
12531 if(PrefDirPos2 > -1)
12533 if(PrefDirPos3 > -1)
12536 if(PrefDirPos3 > -1)
12541 else if(PrefDirPos2 > -1)
12543 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
12554 else if(PrefDirPos1 > -1)
12556 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
12567 else if(PrefDirPos0 > -1)
12569 if(PrefDirElement0.
XLinkPos == EntryPos)
12606 ElementIn.
VLoc +
"," + XLink);
12608 bool TrackFoundFlag;
12611 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
12624 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
12634 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
12649 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
12659 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
12674 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
12684 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
12699 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
12709 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
12732 bool FoundFlag, ContFlag, FoundElements =
false;
12733 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12738 LastIteratorValue++;
12759 if(PDVIt->XLinkPos == 0)
12764 StartElement = *PDVIt;
12773 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
12775 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
12776 if(PrefDirPos0 == -1)
12780 bool NextElementFoundFlag =
false;
12784 NextElementFoundFlag =
true;
12786 if(PrefDirPos1 > -1)
12791 NextElementFoundFlag =
true;
12794 if(PrefDirPos2 > -1)
12799 NextElementFoundFlag =
true;
12802 if(PrefDirPos3 > -1)
12807 NextElementFoundFlag =
true;
12810 if(!NextElementFoundFlag)
12840 EndElement = NextElement;
12844 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
12846 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
12847 if(PrefDirPos0 == -1)
12857 if(PrefDirPos1 > -1)
12865 if(PrefDirPos2 > -1)
12873 if(PrefDirPos3 > -1)
12902 FoundElements =
true;
12936 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
12938 int TrackVectorPosition;
12977 int LockedVectorNumber;
13001 bool InPrefDirFlag =
false;
13004 int PrefDirPos0 = -1;
13005 int PrefDirPos1 = -1;
13006 int PrefDirPos2 = -1;
13007 int PrefDirPos3 = -1;
13011 int PrefDirVecPos[4] =
13012 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13014 for(
int x = 0; x < 4; x++)
13016 int b = PrefDirVecPos[x];
13026 InPrefDirFlag =
true;
13040 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
13049 if(DummyPair.first > -1)
13051 throw Exception(
"Selection in two routes - should never happen!");
13054 if(RoutePair.first > -1)
13130 IDInt &ReqPosRouteID,
bool &PointsChanged)
13164 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
13218 bool InPrefDirFlag =
false;
13221 int PrefDirPos0 = -1;
13222 int PrefDirPos1 = -1;
13223 int PrefDirPos2 = -1;
13224 int PrefDirPos3 = -1;
13227 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
13228 int PrefDirVecPos[4] =
13229 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13231 for(
int x = 0; x < 4; x++)
13233 int b = PrefDirVecPos[x];
13236 InPrefDirFlag =
true;
13246 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
13256 if(RoutePair.first > -1)
13258 if(RoutePair.second != 0)
13275 EndElement1 = RouteElement;
13276 EndElement2 = BlankElement;
13381 PointsChanged =
true;
13408 PointsChanged =
true;
13429 PointsChanged =
true;
13457 PointsChanged =
true;
13471 PointsChanged =
true;
13487 PointsChanged =
true;
13498 PointsChanged =
true;
13514 PointsChanged =
true;
13566 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag)
13619 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
13620 AnsiString((
short)AutoSigsFlag));
13621 int VectorCount = 0;
13625 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
13629 for(
int x = 0; x < VectorCount; x++)
13636 bool FirstPass =
true;
13646 for(
int x = 0; x < VectorCount; x++)
13653 for(
int x = 0; x < VectorCount; x++)
13663 for(
int x = 0; x < VectorCount; x++)
13669 int NextPosition = PrefDirElement.
Conn[XLinkPos];
13673 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
13674 SearchElement.
ELinkPos = NextELinkPos;
13675 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
13688 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
13690 SearchElement.
XLinkPos = NextXLinkPos;
13702 for(
int x = 0; x < VectorCount; x++)
13714 if(RoutePair.first > -1)
13723 for(
int x = 0; x < VectorCount; x++)
13730 if(SecondPair.first > -1)
13739 for(
int x = 0; x < VectorCount; x++)
13752 for(
int x = 0; x < VectorCount; x++)
13761 for(
int x = 0; x < VectorCount; x++)
13768 for(
int x = 0; x < VectorCount; x++)
13776 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13780 for(
int x = 0; x < VectorCount; x++)
13788 bool InPrefDirFlag =
false;
13789 PrefDirElement1 = BlankElement;
13790 PrefDirElement2 = BlankElement;
13793 int PrefDirPos0 = -1;
13794 int PrefDirPos1 = -1;
13795 int PrefDirPos2 = -1;
13796 int PrefDirPos3 = -1;
13799 int PrefDirVecPos[4] =
13800 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13801 for(
int x = 0; x < 4; x++)
13803 int b = PrefDirVecPos[x];
13806 InPrefDirFlag =
true;
13815 for(
int x = 0; x < VectorCount; x++)
13826 for(
int x = 0; x < VectorCount; x++)
13841 for(
int x = 0; x < VectorCount; x++)
13858 for(
int x = 0; x < VectorCount; x++)
13872 for(
int x = 0; x < VectorCount; x++)
13880 for(
int x = 0; x < VectorCount; x++)
13889 int SearchPos1 = SearchElement.
Attribute + 1;
13891 if(SearchPos1 == 2)
13893 if(SearchPos1 == 1)
13897 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
13898 SearchElement.
XLinkPos = SearchPos1;
13899 InPrefDirFlag =
false;
13900 if(SearchElement.
XLink == PrefDirElement1.
XLink)
13902 SearchElement = PrefDirElement1;
13903 InPrefDirFlag =
true;
13905 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
13907 SearchElement = PrefDirElement2;
13908 InPrefDirFlag =
true;
13914 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13918 for(
int x = 0; x < VectorCount; x++)
13943 for(
int x = 0; x < VectorCount; x++)
13959 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
13960 SearchElement.
XLinkPos = SearchPos2;
13961 if(SearchElement.
XLink == PrefDirElement1.
XLink)
13963 SearchElement = PrefDirElement1;
13965 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
13967 SearchElement = PrefDirElement2;
13971 for(
int x = 0; x < VectorCount; x++)
13977 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13981 for(
int x = 0; x < VectorCount; x++)
14007 for(
int x = 0; x < VectorCount; x++)
14017 for(
int x = 0; x < VectorCount; x++)
14024 SearchElement = PrefDirElement1;
14033 XLinkPos = SearchElement.
XLinkPos;
14034 PrefDirElement = SearchElement;
14092 unsigned int TruncatePrefDirPosition = 0;
14166 throw Exception(
"Error - failed to validate extended route for preferred route");
14222 throw Exception(
"Error - failed to validate single route for preferred route");
14267 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
14269 int TrackVectorPosition;
14305 int LockedVectorNumber;
14336 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
14337 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
14340 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
14346 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
14347 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
14350 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
14364 if(RoutePair.first > -1)
14549 EndElement1.
ELink = EndElement1.
Link[0];
14550 EndElement1.
XLink = EndElement1.
Link[1];
14553 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
14558 EndElement2.
ELink = EndElement2.
Link[1];
14559 EndElement2.
XLink = EndElement2.
Link[0];
14562 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
14608 if(RoutePair.first > -1)
14610 if(RoutePair.second != 0)
14629 EndElement2 = BlankElement;
14708 PointsChanged =
true;
14732 PointsChanged =
true;
14752 PointsChanged =
true;
14776 PointsChanged =
true;
14790 PointsChanged =
true;
14828 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
14829 int VectorCount = 0;
14832 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
14833 (CurrentTrackElement.
Link[XLinkPos] == 9))
14837 for(
int x = 0; x < VectorCount; x++)
14848 for(
int x = 0; x < VectorCount; x++)
14853 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
14855 for(
int x = 0; x < VectorCount; x++)
14860 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
14864 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
14865 SearchElement.
ELinkPos = NextELinkPos;
14878 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
14880 SearchElement.
XLinkPos = NextXLinkPos;
14893 for(
int x = 0; x < VectorCount; x++)
14905 if(RoutePair.first > -1)
14914 for(
int x = 0; x < VectorCount; x++)
14921 if(SecondPair.first > -1)
14930 for(
int x = 0; x < VectorCount; x++)
14943 for(
int x = 0; x < VectorCount; x++)
14952 for(
int x = 0; x < VectorCount; x++)
14959 for(
int x = 0; x < VectorCount; x++)
14967 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
14971 for(
int x = 0; x < VectorCount; x++)
14983 for(
int x = 0; x < VectorCount; x++)
15010 for(
int x = 0; x < VectorCount; x++)
15019 for(
int x = 0; x < VectorCount; x++)
15029 int SearchPos1 = SearchElement.
Attribute + 1;
15031 if(SearchPos1 == 2)
15033 if(SearchPos1 == 1)
15038 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15039 SearchElement.
XLinkPos = SearchPos1;
15041 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15045 for(
int x = 0; x < VectorCount; x++)
15068 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15069 SearchElement.
XLinkPos = SearchPos2;
15071 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15075 for(
int x = 0; x < VectorCount; x++)
15092 for(
int x = 0; x < VectorCount; x++)
15104 CurrentTrackElement = SearchElement;
15105 XLinkPos = SearchElement.
XLinkPos;
15127 throw Exception(
"Error, SearchVector empty");
15139 for(
int x = 0; x < 4; x++)
15173 throw Exception(
"Error in EntryExitNumber 3");
15229 unsigned int TruncatePrefDirPosition = 0;
15290 throw Exception(
"Failed to validate extended route for nonpreferred route");
15336 throw Exception(
"Failed to validate single route for nonpreferred route");
15356 if(!PrefDirVector.empty())
15360 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
15365 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
15400 if(!PrefDirVector.empty())
15403 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
15405 int ForwardLinkedRouteNumber, Attribute = 0;
15412 if(ForwardLinkedRouteNumber > -1)
15414 int NextForwardLinkedRouteNumber = -1;
15418 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
15428 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
15447 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
15455 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
15486 NextForwardLinkedRouteNumber = -1;
15487 for(
unsigned int x = 0; x < PrefDirSize(); x++)
15489 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
15490 if(PrefDirVector.at(x).TrackType ==
Bridge)
15492 if(PrefDirVector.at(x).XLinkPos < 2)
15493 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos01;
15495 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos23;
15502 if(PrefDirVector.at(x).TrackType ==
Buffers)
15514 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
15523 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
15525 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute + 1;
15531 if(x == PrefDirSize() - 1)
15573 AnsiString(PrefDirVectorStartPosition));
15578 bool SkipContinuationAndBufferAttributeChange =
false;
15580 if(!PrefDirVector.empty())
15582 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
15585 if(PrefDirPtr->TrackType ==
Bridge)
15587 if(PrefDirPtr->XLinkPos < 2)
15594 SkipContinuationAndBufferAttributeChange =
true;
15609 SkipContinuationAndBufferAttributeChange =
true;
15617 SkipContinuationAndBufferAttributeChange =
true;
15619 if(!SkipContinuationAndBufferAttributeChange)
15621 if(PrefDirVector.back().TrackType ==
Buffers)
15627 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
15630 if(PrefDirPtr->TrackType ==
Bridge)
15632 if(PrefDirPtr->XLinkPos < 2)
15644 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
15653 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
15655 if((!
AllRoutes->
RouteTruncateFlag) || (PrefDirPtr != (PrefDirVector.begin() + PrefDirVectorStartPosition)) || PrefDirPtr->AutoSignals ||
15656 PrefDirPtr->PrefDirRoute)
15697 "," + AnsiString((
short)PrefDirRoute));
15698 bool ElementInRoute =
false;
15699 bool TrainOccupyingRoute =
false;
15705 ElementInRoute =
true;
15709 if(!ElementInRoute)
15733 TrainOccupyingRoute =
true;
15801 if(LRVIT->RouteNumber == RouteNumber)
15816 int button = Application->MessageBox(L
"Train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
15817 L
"Warning!", MB_YESNO | MB_ICONWARNING);
15829 bool ExistingLockedRouteModified =
false;
15842 if(LRVIT->RouteNumber == RouteNumber)
15846 ExistingLockedRouteModified =
true;
15850 if(!ExistingLockedRouteModified)
15938 AnsiString((
short)PrefDirRoute));
15963 AnsiString((
short)PrefDirRoute));
15973 RouteFlashElement.
HLoc = H;
15974 RouteFlashElement.
VLoc = V;
15990 int H = PrefDirPtr->HLoc;
15991 int V = PrefDirPtr->VLoc;
16056 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
16060 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
16063 OverlayPlotted =
false;
16073 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
16075 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
16078 return AllRoutesVector.at(At);
16087 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
16089 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
16092 return AllRoutesVector.at(At);
16103 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16105 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
16115 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16117 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
16135 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
16136 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16139 RouteTruncateFlag =
true;
16141 GetModifiableRouteAt(7, a).GetRouteTruncateElement(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
16142 RouteTruncateFlag =
false;
16169 AnsiString(LinkPos));
16170 if(TrackVectorPosition == -1)
16175 THVPair Route2MultiMapKeyPair;
16179 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16182 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16192 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16194 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16197 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
16198 Route2MultiMapIterator->second.second);
16199 EntryLinkPos = PrefDirElement1.
ELinkPos;
16200 ExitLinkPos = PrefDirElement1.
XLinkPos;
16201 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16202 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16214 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16226 Graphics::TBitmap* &EntryDirectionGraphicPtr)
16236 AnsiString(LinkPos));
16239 if(TrackVectorPosition == -1)
16244 THVPair Route2MultiMapKeyPair;
16248 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16251 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16256 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16258 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16260 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
16261 Route2MultiMapIterator->second.second);
16262 EntryLinkPos = PrefDirElement1.
ELinkPos;
16263 ExitLinkPos = PrefDirElement1.
XLinkPos;
16264 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16265 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16269 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
16270 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
16277 return AutoSigsRoute;
16282 return NotAutoSigsRoute;
16288 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
16289 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
16296 return AutoSigsRoute;
16301 return NotAutoSigsRoute;
16305 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16307 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16308 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16310 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
16311 EntryLinkPos = PrefDirElement2.
ELinkPos;
16312 ExitLinkPos = PrefDirElement2.
XLinkPos;
16313 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
16314 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
16318 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
16325 return AutoSigsRoute;
16330 return NotAutoSigsRoute;
16336 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
16343 return AutoSigsRoute;
16348 return NotAutoSigsRoute;
16353 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
16354 EntryLinkPos = PrefDirElement3.
ELinkPos;
16355 ExitLinkPos = PrefDirElement3.
XLinkPos;
16356 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
16357 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
16361 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
16368 return AutoSigsRoute;
16373 return NotAutoSigsRoute;
16379 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
16386 return AutoSigsRoute;
16391 return NotAutoSigsRoute;
16407 AnsiString(LinkPos));
16408 if(TrackVectorPosition == -1)
16414 THVPair Route2MultiMapKeyPair;
16418 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16421 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16427 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16429 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16431 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
16432 Route2MultiMapIterator->second.second);
16433 EntryLinkPos = PrefDirElement1.
ELinkPos;
16434 ExitLinkPos = PrefDirElement1.
XLinkPos;
16435 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16436 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16439 RouteNumber = Route2MultiMapIterator->second.first;
16443 return AutoSigsRoute;
16448 return NotAutoSigsRoute;
16453 RouteNumber = Route2MultiMapIterator->second.first;
16457 return AutoSigsRoute;
16462 return NotAutoSigsRoute;
16466 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16468 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16469 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16471 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
16472 EntryLinkPos = PrefDirElement2.
ELinkPos;
16473 ExitLinkPos = PrefDirElement2.
XLinkPos;
16474 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
16475 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
16478 RouteNumber = ItPair.first->second.first;
16482 return AutoSigsRoute;
16487 return NotAutoSigsRoute;
16492 RouteNumber = ItPair.first->second.first;
16496 return AutoSigsRoute;
16501 return NotAutoSigsRoute;
16506 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
16507 EntryLinkPos = PrefDirElement3.
ELinkPos;
16508 ExitLinkPos = PrefDirElement3.
XLinkPos;
16509 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
16510 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
16513 RouteNumber = ItPair.second->second.first;
16517 return AutoSigsRoute;
16522 return NotAutoSigsRoute;
16527 RouteNumber = ItPair.second->second.first;
16531 return AutoSigsRoute;
16536 return NotAutoSigsRoute;
16558 EmptyRoute.
RouteID = NextRouteID;
16561 AllRoutesVector.push_back(EmptyRoute);
16562 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
16587 AllRoutesVector.push_back(EmptyRoute);
16588 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
16611 THVPair Route2MultiMapKeyPair;
16620 LockedRouteTruncateTrackVectorPosition = 0;
16621 LockedRouteLastTrackVectorPosition = 0;
16622 LockedRouteLastXLinkPos = 0;
16623 LockedRouteLockStartTime = TDateTime(0);
16624 if(!LockedRouteVector.empty())
16628 if(LRVIT->RouteNumber == RouteNumber)
16630 LockedRouteTruncateTrackVectorPosition = LRVIT->TruncateTrackVectorPosition;
16631 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
16632 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
16633 LockedRouteLockStartTime = LRVIT->LockStartTime;
16634 LockedRouteFoundDuringRouteBuilding =
true;
16635 LockedRouteVector.erase(LRVIT);
16661 AnsiString(VLoc) +
"," + AnsiString(ELink));
16664 ReturnPair.first = -1;
16665 ReturnPair.second = 0;
16666 THVPair Route2MultiMapKeyPair;
16668 Route2MultiMapKeyPair.first = HLoc;
16669 Route2MultiMapKeyPair.second = VLoc;
16672 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
16673 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16675 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16676 Route2MultiMapIterator = ItPair.first;
16678 if(ItPair.first == ItPair.second)
16680 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
16683 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
16685 ReturnPair.first = ItPair.first->second.first;
16686 ReturnPair.second = ItPair.first->second.second;
16687 Route2MultiMapIterator = ItPair.first;
16692 if(ItPair.first == ItPair.second)
16694 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
16696 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
16698 ReturnPair.first = ItPair.first->second.first;
16699 ReturnPair.second = ItPair.first->second.second;
16700 Route2MultiMapIterator = ItPair.first;
16720 AnsiString(VLoc) +
"," + AnsiString(ELink));
16721 THVPair Route2MultiMapKeyPair;
16723 Route2MultiMapKeyPair.first = HLoc;
16724 Route2MultiMapKeyPair.second = VLoc;
16725 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16727 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16729 if(ItPair.first == ItPair.second)
16736 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
16738 RouteNumber = ItPair.first->second.first;
16745 if(ItPair.first == ItPair.second)
16752 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
16754 RouteNumber = ItPair.first->second.first;
16775 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
16776 THVPair Route2MultiMapKeyPair;
16778 Route2MultiMapKeyPair.first = HLoc;
16779 Route2MultiMapKeyPair.second = VLoc;
16782 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
16785 RouteElementPair.first = RouteNumber;
16786 RouteElementPair.second = RouteElementNumber;
16787 Route2MultiMapEntry.second = RouteElementPair;
16789 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
16792 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
16793 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
16796 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
16797 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
16799 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
16801 Route2MultiMap.insert(Route2MultiMapEntry);
16806 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
16810 Route2MultiMap.insert(Route2MultiMapEntry);
16827 TempPair.first = -1;
16828 TempPair.second = 0;
16829 SecondPair = TempPair;
16831 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
16832 THVPair Route2MultiMapKeyPair;
16834 Route2MultiMapKeyPair.first = HLoc;
16835 Route2MultiMapKeyPair.second = VLoc;
16836 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16841 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16843 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16845 return Route2MultiMapIterator->second;
16847 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16849 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16850 TempPair = ItRange.first->second;
16851 SecondPair = (--ItRange.second)->second;
16874 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
16875 if(RouteElementPair.first == -1)
16878 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
16879 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
16881 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
16884 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
16885 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
16886 (AnsiString)Caller);
16888 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
16891 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
16892 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
16893 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
16894 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
16898 unsigned int SizeVal = 0;
16901 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16903 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
16905 if(SizeVal != Route2MultiMap.size())
16907 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
16908 (AnsiString)Caller);
16924 if(!Route2MultiMap.empty())
16926 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
16928 if(Route2MultiMapIterator->second.first > RouteNumber)
16929 Route2MultiMapIterator->second.first--;
16945 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
16946 if(!Route2MultiMap.empty())
16948 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
16950 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
16951 Route2MultiMapIterator->second.second--;
16969 AnsiString(ELink));
16973 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
16974 if(RequiredRoutePair.first == -1)
16976 throw Exception(
"Failed to find route element in RemoveRouteElement");
16978 Route2MultiMap.erase(Route2MultiMapIterator);
16979 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
16982 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
17004 GetModifiableRouteAt(8, RequiredRoutePair.first).EraseRouteElementAt(&(GetModifiableRouteAt(9, RequiredRoutePair.first).GetModifiablePrefDirElementAt(1,
17005 RequiredRoutePair.second)));
17016 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
17025 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
17027 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
17028 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
17029 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
17041 if(!LockedRouteVector.empty())
17045 if(LRVIT->RouteNumber > RequiredRoutePair.first)
17047 LRVIT->RouteNumber--;
17058 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
17059 AutoSigVectorIT->RouteNumber--;
17063 CheckMapAndRoutes(7);
17077 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
17078 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
17079 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
17095 "," + AnsiString(XLinkPos));
17099 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
17100 if(RouteElementPair.first == -1)
17102 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
17104 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
17106 RequiredPair = RouteElementPair;
17107 if(RouteElement.
XLinkPos != XLinkPos)
17109 if(SecondPair.first != -1)
17111 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
17112 RequiredPair = SecondPair;
17113 if(RouteElement.
XLinkPos != XLinkPos)
17115 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
17120 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
17125 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
17145 AnsiString(AccessNumber));
17147 int Attribute = AccessNumber + 1;
17149 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
17153 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
17157 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
17160 x).XLinkPos] !=
End)
17162 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
17165 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
17207 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
17208 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
17209 int RearwardLinkedRouteNumber;
17233 int TrainID, TrainPosition, BehindTrainPosition;
17234 bool FoundTrain =
false, BehindTrain =
false;
17235 for(
int x = RouteStartPosition; x >= 0; x--)
17237 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
17256 if(FoundTrain && (TrainPosition > 1))
17258 for(
int x = TrainPosition; x >= 0; x--)
17263 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
17277 BehindTrain =
true;
17278 BehindTrainPosition = x;
17285 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
17302 AnsiString(RouteTruncatePosition));
17303 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber, StartPosition = RouteTruncatePosition;
17304 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
17307 bool ExamineRoute =
true;
17309 while(ExamineRoute)
17311 for(
int x = StartPosition; x >= 0; x--)
17348 if(SignalCount >= 3)
17367 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
17368 ExamineRoute =
true;
17369 StartPosition = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
17400 ExamineRoute =
false;
17415 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
17418 PrefDirElement = InternalPrefDirElement;
17419 if(LockedRouteVector.empty())
17426 bool InLockedRoute =
false;
17430 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
17433 InLockedRoute =
true;
17443 int RouteNumber, VectorCount = 0;
17448 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
17449 if(RouteType == NoRoute)
17453 GetFixedRouteAt(140, RouteNumber).
PrefDirSize() - 1).XLinkPos != LRVIT->LastXLinkPos))
17456 (
"Error, last element in locked route doesn't correspond with last element in associated route in IsElementInLockedRouteGetPrefDirElement");
17458 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
17460 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
17461 if(InternalPrefDirElement.
TrackVectorPosition != (
int)LRVIT->TruncateTrackVectorPosition)
17465 PrefDirElement = InternalPrefDirElement;
17466 LockedVectorNumber = VectorCount;
17471 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->TruncateTrackVectorPosition)
17475 PrefDirElement = InternalPrefDirElement;
17476 LockedVectorNumber = VectorCount;
17495 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17497 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
17503 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
17513 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17515 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
17530 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17532 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
17535 return GetFixedRouteAt(159, x);
17538 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
17546 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17548 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
17551 return GetModifiableRouteAt(15, x);
17554 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
17564 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17566 TOneRoute OneRoute = GetFixedRouteAt(165, x);
17578 int NumberOfRoutes;
17582 for(
int x = 0; x < NumberOfRoutes; x++)
17589 StoreOneRouteAfterSessionLoad(0, &OneRoute);
17607 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
17614 if((NextID < 0) || (NextID > 1000000))
17619 for(
int x = 0; x < NumberOfRoutes; x++)
17643 AnsiString(StartPosition));
17644 if(EndPosition == StartPosition)
17650 int TVPos = EndPosition;
17651 int LkPos = EndXLinkPos;
17653 while(TrackIsInARoute(15, TVPos, LkPos))
17680 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
17689 if((NewLkPos == 0) || (NewLkPos == 2))
17701 if(TVPos == StartPosition)
17733 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
17738 if(FirstPair.first > -1)
17741 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17746 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17752 if(SecondPair.first > -1)
17755 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17760 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17767 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
17775 if(FirstPair.first > -1)
17778 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17783 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17789 if(SecondPair.first > -1)
17792 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17797 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17804 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
17812 if(FirstPair.first > -1)
17815 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17820 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17826 if(SecondPair.first > -1)
17829 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17834 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17841 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
17849 if(FirstPair.first > -1)
17852 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17857 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17863 if(SecondPair.first > -1)
17866 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17871 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17878 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
17903 "," + AnsiString(DiagonalLinkNumber));
17908 if(FirstPair.first > -1)
17911 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17916 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17922 if(SecondPair.first > -1)
17925 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17930 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17938 if(FirstPair.first > -1)
17941 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17946 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17952 if(SecondPair.first > -1)
17955 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17960 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17968 if(FirstPair.first > -1)
17971 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17976 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17982 if(SecondPair.first > -1)
17985 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17990 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17998 if(FirstPair.first > -1)
18001 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
18006 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
18012 if(SecondPair.first > -1)
18015 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
18020 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))